<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<script src="js/axios.min.js"></script>
<script src="js/vue.min.js"></script>
<script src="js/jquery.min.js"></script>
<body >
  <div id="app">
    <div>
      <p>api/user</p>
      <button @click="addUser">add</button>
      <button @click="userList">userList</button>
    </div>
    <div>
      <p>api/user</p>
      <button @click="addUser">add</button>
      <button @click="userList">userList</button>
      <p>api/file</p>
      <input type="file" @change="changePart" name="" id="">
    </div>
  </div>
</body>
<script>
  new Vue({
    el: '#app',
    data: {
      message: '<h1>菜鸟教程</h1>'
    },
    methods: {
      addUser () {
        var obj = {
          username: 'mm',
          createAt: new Date().getDate(),
          updateAt: new Date().getDate(),
        }
        axios.post('/api/saveUser', obj);
      },
      userList () {
        axios.get('/api/userList');
      },
      changePart (e) {
        let files = e.target.files,
            i = 0,
            _data,
            formData = new FormData();
            for (; i < files.length; i++) {
            console.log(files[i]);
              formData.append('file', files[i], [i].name);
              formData.append('file', i);
            }
            console.log(formData);
        axios.post('/api/uploadFile', formData);
      }
    }
  })
</script>
</html>